Enable python binding
authorFelix Yan <felixonmars@archlinux.org>
Fri, 2 Aug 2024 09:02:12 +0000 (12:02 +0300)
committerShengjing Zhu <zhsj@debian.org>
Sat, 3 Aug 2024 06:13:59 +0000 (14:13 +0800)
Co-authored-by: Shengjing Zhu <zhsj@debian.org>
debian/control
debian/python3-opencc.install [new file with mode: 0644]
debian/rules

index b0a37842da68b5e5c528b8d295883be7d3d98aa1..aff8d509922116fd16deba6473c2f6c79bb12fa7 100644 (file)
@@ -10,9 +10,11 @@ Uploaders:
  xiao sheng wen <atzlinux@sina.com>,
  Boyuan Yang <byang@debian.org>,
 Build-Depends:
+ chrpath,
  cmake,
  darts,
  debhelper-compat (= 13),
+ dh-python,
  doxygen <!nodoc>,
  googletest <!nocheck>,
  libmarisa-dev,
@@ -20,8 +22,10 @@ Build-Depends:
  opencc <cross>,
  dh-sequence-pkgkde-symbolshelper,
  pybind11-dev,
- python3:any,
+ python3-dev,
  rapidjson-dev,
+ python3-setuptools,
+ python3-wheel,
 Standards-Version: 4.6.2
 Rules-Requires-Root: no
 Section: libs
@@ -100,3 +104,16 @@ Description: simplified-traditional Chinese conversion tool
  simplified Chinese.
  .
  This package includes the conversion tool.
+
+Package: python3-opencc
+Section: python
+Architecture: any
+Depends:
+ ${misc:Depends},
+ ${python3:Depends},
+ ${shlibs:Depends},
+Description: simplified-traditional Chinese conversion library - Python 3.x
+ opencc is a library for converting character between traditional Chinese and
+ simplified Chinese.
+ .
+ This package provides the Python 3.x module.
diff --git a/debian/python3-opencc.install b/debian/python3-opencc.install
new file mode 100644 (file)
index 0000000..4606faa
--- /dev/null
@@ -0,0 +1 @@
+usr/lib/python3*
index 2dd7d65bd474f594fbce404259addc53622e476e..26baabeeafe92d498c3e2c1ff3ed26f43a888463 100755 (executable)
@@ -11,12 +11,13 @@ include /usr/share/dpkg/architecture.mk
 # Disable parallel build to circumvent some random build error
 # (needs further investigation)
 %:
-       dh $@ --buildsystem=cmake --no-parallel
+       dh $@ --with python3 --buildsystem=cmake --no-parallel
 
 BUILD_OPTIONS = \
     -DCMAKE_INSTALL_PREFIX=/usr \
     -DCMAKE_INSTALL_LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH)/ \
     -DCMAKE_BUILD_TYPE=Release \
+    -DBUILD_PYTHON=ON \
     -DUSE_SYSTEM_DARTS=ON \
     -DUSE_SYSTEM_GTEST=ON \
     -DUSE_SYSTEM_MARISA=ON \
@@ -39,6 +40,21 @@ endif
 override_dh_auto_configure:
        dh_auto_configure -- $(BUILD_OPTIONS)
 
+execute_after_dh_auto_build:
+       dh_auto_build -O--buildsystem=pybuild -- -s distutils --after-build \
+               "cp obj-$(DEB_BUILD_GNU_TYPE)/opencc_clib.*.so {build_dir}/opencc/clib/"
+
+execute_after_dh_auto_test:
+       dh_auto_test -O--buildsystem=pybuild -- -s distutils
+
+execute_after_dh_auto_install:
+       dh_auto_install -O--buildsystem=pybuild -- -s distutils
+       chrpath --delete debian/tmp/usr/lib/*/dist-packages/opencc/clib/*.so
+       for i in debian/tmp/usr/lib/*/dist-packages/opencc/clib/; do \
+               mkdir -p $$i/share/; \
+               ln -sf ../../../../../../share/opencc $$i/share/; \
+       done
+
 execute_after_dh_auto_clean:
        find . -name *.pyc -delete